package com.ruoyi.inspection.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.inspection.domain.FzInspectionDian;
import com.ruoyi.inspection.domain.FzInspectionRouteInfo;
import com.ruoyi.inspection.mapper.FzInspectionDianMapper;
import com.ruoyi.inspection.mapper.FzInspectionRouteInfoMapper;
import com.ruoyi.inspection.service.IFzInspectionDianService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.text.Convert;

/**
 * 巡检点Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-03-13
 */
@Service
public class FzInspectionDianServiceImpl implements IFzInspectionDianService
{
    @Autowired
    private FzInspectionDianMapper fzInspectionDianMapper;

    /**
     * 查询巡检点
     * 
     * @param inspectionId 巡检点ID
     * @return 巡检点
     */
    @Override
    public FzInspectionDian selectFzInspectionDianById(String inspectionId)
    {
        return fzInspectionDianMapper.selectFzInspectionDianById(inspectionId);
    }

    /**
     * 查询巡检点列表
     * 
     * @param fzInspectionDian 巡检点
     * @return 巡检点
     */
    @Override
    public List<FzInspectionDian> selectFzInspectionDianList(FzInspectionDian fzInspectionDian)
    {
        return fzInspectionDianMapper.selectFzInspectionDianList(fzInspectionDian);
    }

    /**
     * 新增巡检点
     * 
     * @param fzInspectionDian 巡检点
     * @return 结果
     */
    @Override
    public int insertFzInspectionDian(FzInspectionDian fzInspectionDian)
    {
        fzInspectionDian.setCreateTime(DateUtils.getNowDate());
        return fzInspectionDianMapper.insertFzInspectionDian(fzInspectionDian);
    }

    /**
     * 修改巡检点
     * 
     * @param fzInspectionDian 巡检点
     * @return 结果
     */
    @Override
    public int updateFzInspectionDian(FzInspectionDian fzInspectionDian)
    {
        fzInspectionDian.setUpdateTime(DateUtils.getNowDate());
        return fzInspectionDianMapper.updateFzInspectionDian(fzInspectionDian);
    }

    /**
     * 删除巡检点对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteFzInspectionDianByIds(String ids)
    {
        return fzInspectionDianMapper.deleteFzInspectionDianByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除巡检点信息
     * 
     * @param inspectionId 巡检点ID
     * @return 结果
     */
    @Override
    public int deleteFzInspectionDianById(String inspectionId)
    {
        return fzInspectionDianMapper.deleteFzInspectionDianById(inspectionId);
    }

    @Autowired
    private FzInspectionRouteInfoMapper fzInspectionRouteInfoMapper;
    @Override
    public List<FzInspectionDian> selectFzInspectionDianListByRouteId(FzInspectionDian fzInspectionDian,String routeId) {
        List<String> list= fzInspectionRouteInfoMapper.selectFzInspectionRouteInfoIdById(routeId);

        fzInspectionDian.setInspectionIdList((list.size()==0)?null : list);
        return fzInspectionDianMapper.selectFzInspectionDianListByRouteId(fzInspectionDian);
    }


    //查询指定id巡检点
    public List<FzInspectionDian> selectFzInspectionDianListById(List<String> list){
        return fzInspectionDianMapper.selectFzInspectionDianByIdList(list);
    }
}
